import { defineStore } from 'pinia'
import {componentConfigType} from '@/packages/index.d'
interface dragState{
  dragData:any,
  componentList: Array<componentConfigType>,
  currentComponent:any
}

export const useDragEdit = defineStore('useDragEdit', {
  state: ():dragState => (
    {
      dragData: {
      
      },
      componentList: [],
      currentComponent:{}
      
}
  ),
  getters: {
    dargData:(dragData) =>dragData,
    getComponentList(): Array<componentConfigType> {
      return this.componentList;
    },
    getTargetChart(): componentConfigType {
      return this.currentComponent;
    },
  },
  actions: {
    addNewData() {
      //异步可以调用其他action
      // this.dragData
    },
    addComponentList(component: componentConfigType) {
      this.componentList.push(component)
    },
    setCurrentComponent(component: componentConfigType) {
      this.currentComponent = component
    }
  }
})